<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>dom节点的遍历</title>
</head>
<body>
    <div></div>
    <div></div>

    <script>
        const nodeList = document.querySelectorAll('div');
        const collection = document.getElementsByTagName('div');

        // 都可以使用for...of..遍历
        // for (const node of nodeList) {
        //     console.log(node);
        // }

        // for (const node of collection) {
        //     console.log(node);
        // }

        // 列表可以使用forEach遍历，集合不可以
        // nodeList.forEach(node => {
        //     console.log(node);
        // })

        // 把他们转化为数组进行遍历
        Array.prototype.map.call(nodeList,node => {
            console.log(node);
        });

        Array.from(nodeList).map(node => {
            console.log(node);
        });

        [...nodeList].map(node => {
            console.log(node);
        });
    </script>
</body>
</html>